#include <stdio.h>
#include "studentList.h"

void Save_Student_Data(STUDENT *head,FILE *p){
	if (p == NULL || head == NULL){
		return;
	}
	STUDENT *phead = head->next;
	fprintf(p,"<?xml version=""1.0"" encoding=""utf-8""?>\n");
	while (phead != NULL){
		fprintf(p,"<STUDENT\n");
		fprintf(p,"  number = \"%s\"\n", phead->number);
		fprintf(p,"  name = \"%s\"\n", phead->name);
		fprintf(p,"  phone = \"%s\"\n", phead->phone);
		if (phead->scores != NULL)
		{
			fprintf(p,"  <SCORES\n");
			fprintf(p,"    Chinese = \"%d\"\n", phead->scores->Chinese);
			fprintf(p,"    Math = \"%d\"\n", phead->scores->Math);
			fprintf(p,"    English = \"%d\"\n", phead->scores->English);
			fprintf(p,"  />\n");
		}
		fprintf(p,"/>\n");
		phead = phead->next;
	}
}
